package com.example.java_chatroom.service;

import com.example.java_chatroom.mapper.UserInfoMapper;
import com.example.java_chatroom.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    public UserInfo queryUserByName(String userName) {
        return userInfoMapper.selectByName(userName);
    }

    public Integer insert(UserInfo userInfo) {
        return userInfoMapper.insert(userInfo);
    }

    public List<String> queryUserByNames(String message , Integer userId) {
        return userInfoMapper.queryUserByNames(message, userId);
    }


    public UserInfo queryUserById(Integer userId) {
        return userInfoMapper.queryUserById(userId);
    }

    public void updateUserInfo(Integer userId, String userName) {
     userInfoMapper.updateUserInfo(userId, userName);
    }

    public List<UserInfo> queryUserInfoAll() {
      return   userInfoMapper.queryUserInfoAll();
    }

    public void deleteUserByUserId(Integer userId) {
        userInfoMapper.deleteUserByUserId(userId);
    }

    public void updateCode(int i, String userName) {
        userInfoMapper.updateCode(i, userName);
    }

    public String queryUserNameById(Integer friendId) {
      return   userInfoMapper.queryUserNameById(friendId);
    }
}
